import * as echarts from "echarts";

export function safeInitChart(domId, option) {
    const dom = document.getElementById(domId);
    const existChart = echarts.getInstanceByDom(dom);
    existChart && existChart.dispose();
    const chart = echarts.init(dom);
    chart.setOption(option);
    return chart;
}